package entity;

import java.util.Date;
import java.util.Objects;
import java.util.StringJoiner;

public class Products {

    private String id;  //编号
    private String name;  //名称
    private String suppliperId;  //供应商编码
    private int inventory;  //库存
    private double cost;  //成本
    private double price;  // 售价
    private Date joinData;  //入库时间

    public Products(String id, String name, String suppliperId, int inventory, double cost, double price, Date joinData) {
        this.id = id;
        this.name = name;
        this.suppliperId = suppliperId;
        this.inventory = inventory;
        this.cost = cost;
        this.price = price;
        this.joinData = joinData;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSuppliperId() {
        return suppliperId;
    }

    public void setSuppliperId(String suppliperId) {
        this.suppliperId = suppliperId;
    }

    public int getInventory() {
        return inventory;
    }

    public void setInventory(int inventory) {
        this.inventory = inventory;
    }

    public double getCost() {
        return cost;
    }

    public void setCost(double cost) {
        this.cost = cost;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public Date getJoinData() {
        return joinData;
    }

    public void setJoinData(Date joinData) {
        this.joinData = joinData;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Products)) return false;
        Products products = (Products) o;
        return getInventory() == products.getInventory() &&
                Double.compare(products.getCost(), getCost()) == 0 &&
                Double.compare(products.getPrice(), getPrice()) == 0 &&
                getId().equals(products.getId()) &&
                getName().equals(products.getName()) &&
                getSuppliperId().equals(products.getSuppliperId()) &&
                getJoinData().equals(products.getJoinData());
    }

    @Override
    public int hashCode() {
        return Objects.hash(getId(), getName(), getSuppliperId(), getInventory(), getCost(), getPrice(), getJoinData());
    }

    @Override
    public String toString() {
        return new StringJoiner(", ", Products.class.getSimpleName() + "[", "]")
                .add("id='" + id + "'")
                .add("name='" + name + "'")
                .add("suppliperId='" + suppliperId + "'")
                .add("inventory=" + inventory)
                .add("cost=" + cost)
                .add("price=" + price)
                .add("joinData=" + joinData)
                .toString();
    }
}
